
#import "SMAuthManager.h"
#import "SMConstants.h"

@implementation SMAuthManager
+ (instancetype)shared {
    static SMAuthManager *mgr;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{ mgr = [SMAuthManager new]; });
    return mgr;
}
- (BOOL)isLoggedIn { return [self token].length > 0; }
- (void)logout { [[NSUserDefaults standardUserDefaults] removeObjectForKey:kSMAuthTokenKey]; }
- (void)saveToken:(NSString *)token { if (token.length) [[NSUserDefaults standardUserDefaults] setObject:token forKey:kSMAuthTokenKey]; }
- (NSString *)token { return [[NSUserDefaults standardUserDefaults] stringForKey:kSMAuthTokenKey]; }
@end
